[C#] A problem of downloading webpage's HTML source.

Posted by Nam Gi VU on Stack Overflow See other posts from Stack Overflow or by Nam Gi VU
Published on 2010-03-25T09:10:25Z Indexed on 2010/03/25 9:13 UTC
Read the original article Hit count: 606

Filed under:
|
|
|
|

I use System.Net.WebClient.DownloadString(url) to get the HTML source of http://kqxs.vn but what I recieved is a caution text from the web server which says in Vietnamese as:

"Xin loi. Chung toi khong the dap ung yeu cau truy cap cua ban... Vui long lien he : [email protected]. Chao ban"

which is translated in English as

"Sorry. We cannot response to your request... Please contact... Good bye."

This is strange because when I use a WebControl to get the HTML ( by calling .Navigate(url) and then .DocumentText), I receive the different HTML codes - which in turn is exactly what I see when open the website by Firefox & view the source code from Firefox.

I read DownloadData() is downloading source that is completely wrong. Source view in Firefox different than that downloaded. - Stack Overflow and found the answer to my symptom. But I don't know how to set the User-Agent. Please help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about html